package com.slkj;

import com.slkj.util.IdWorker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@EnableAspectJAutoProxy
@ServletComponentScan(basePackages = {"com.slkj.filter"})
@MapperScan(basePackages = "com.slkj.mapper")
public class TlSlkjApplication {
    //机器号
    @Value("${workerId}")
    //种子
    private Long workerId;
    @Value("${datacenterId}")
    private Long datacenterId;


    public static void main(String[] args) {
        SpringApplication.run(TlSlkjApplication.class, args);
    }


    //初始化ID算法生成器。雪花算法。交给spring
    @Bean
    public IdWorker initIdworker() {
        return new IdWorker(workerId, datacenterId);
    }

}
